// app.js
App({
  onLaunch() {
    wx.getSystemInfo({
      success: (res) => {
        // console.log(res);
        this.globalData.screenW = res.screenWidth;
        this.globalData.screenH = res.screenHeight;
        this.globalData.windowH = res.windowHeight;
        this.globalData.windowW = res.windowWidth;
      },
    });
    this.getToken();
    // console.log(this.globalData);
  },

  //获取Access Token
  getToken() {
    // 参考链接：https://ai.baidu.com/ai-doc/REFERENCE/Ck3dwjhhu
    let client_id = "";//换进自己应用的API Key
    let client_secret = "";//换进自己应用的Secret Key
    let url = `https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=${client_id}&client_secret=${client_secret}&`;
    wx.request({
      url: url,
      method: "POST",
      success: (res) => {
        // console.log(res);
        this.globalData.token = res.data.access_token;
      },
    });
  },

  globalData: {
    screenW: 0,
    screenH: 0,
    picList: [], //所有裁剪好的图片列表
    token: "",
    windowH: 0,
    windowW: 0,
  },
});
